<?php
/**
 * 控制器基类
 * @author andery <andery@foxmail.com>
 * @link http://www.minophp.com/
 * @version $Id: CController.php 2009-07-28 09:15:33Z andery $
 */
class CController
{
	// 视图实例对象
    protected $view = null;
    
	public function __construct(){
	    header("Content-Type: text/html; charset=utf-8");
	}
	
	/**
	 * 初始化视图连接
	 */
	private function _iniView()
	{
	    $this->view = CView::getInstance();
	}
	
	/**
	 * 显示视图
	 * @param string $tplfile 视图名
	 * @param array $tpl_data 传递给视图的变量数组
	 */
	protected function display($tplfile, $tpl_data)
	{
	    $this->_iniView();
		$this->view->display($tplfile, $tpl_data);
	}
	
	/**
	 * 设置视图变量
	 * 
	 */
	protected function assign($tpl_data, $value = '')
    {
        $this->_iniView();
        if (!is_array($tpl_data) && $tpl_data != '') {
            $this->view->assign($tpl_data, $value);
        } else {
            $this->view->assign($tpl_data);
        }
    }
}
